<?php
require_once('adodb/adodb.inc.php');
require_once('adodb/adodb-exceptions.inc.php');

$db = NewADOConnection('mysql');

try {
	//$db->Connect("mysql.nixiweb.com", "u172676809_fcac", "metalmilitia1982");
	$db->Connect("localhost", "root", "admin");
	mysql_query("SET NAMES 'utf8'");
}catch(exception $e){
	die("No se puede conectar");
}

function sql($sql, $variables){
	global $db;
	try{
		return $db->Execute($sql, $variables);
	}catch(exception $e){
		die($db->ErrorMsg().' en: '.$sql);
	}
}

function siguiente(&$res){
	return $res->FetchNextObject($toupper=true);
}

function ComenzarTransaccion(){
	global $db;
	$db->StartTrans();
}

function FinalizarTransaccion(){
	global $db;
	$db->CompleteTrans(true);
}

function sp($sql,$variables){
	$stmt    = odbc_prepare($db, $sql);
	$success = odbc_execute($stmt, $variables);
	return $success;
}